package Text12;

import java.util.*;

public class Main {
    static int N = 30, n, m;
    static char[][] g = new char[N][N];
    static boolean[][] st = new boolean[N][N];
    static int[] dx = {-1, 1, 0, 0};
    static int[] dy = {0, 0, -1, 1};

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (true) {
            m = in.nextInt();
            n = in.nextInt();
            if (n == 0 && m == 0) {
                break;
            }
            for (int i = 0; i < n; i++) {
                g[i] = in.next().toCharArray();
            }
            PII start = null;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (g[i][j] == '@') {
                        start = new PII(i, j);
                    }
                }
            }
            System.out.println(bfs(start));
        }

    }

    private static int bfs(PII start) {
        Queue<PII> q = new LinkedList<>();
        for (int i = 0; i < n; i++) {
            Arrays.fill(st[i], false);
        }
        q.offer(start);
        st[start.x][start.y] = true;
        int res=1;
        while (!q.isEmpty()) {
            PII tmp = q.poll();
            for (int i = 0; i < 4; i++) {
                int x = tmp.x + dx[i];
                int y = tmp.y + dy[i];
                if (x < 0 || x >= n || y < 0 || y >= m) {
                    continue;
                }
                if(st[x][y]){
                    continue;
                }
                if(g[x][y]!='.'){
                    continue;
                }
                res++;
                st[x][y]=true;
                q.offer(new PII(x,y));
            }
        }
        return res;
    }
}

class PII {
    int x, y;

    public PII(int x, int y) {
        this.x = x;
        this.y = y;
    }
}